#include <bits/stdc++.h>
using namespace std;

char command[100], fin[10] = "fin", fout[10] = "fout";

int main(int argc, char const *argv[])
{
    puts("=============================");
    puts("- ");
    puts("- Weaver_zhu's ACM training field V1.0");
    puts("- All rights reserved :)");
    puts("- ");
    printf("- Command: ");
    for (int i=1; i<argc; ++i) printf("%s ", argv[i]);
    puts("- ");
    puts("==============================");
    

    assert(argc >= 2);
    sprintf(command, "g++ %s -o ./bin/main -std=c++11 -O2", argv[1]);
    printf("Command: %s\n", command);
    int ret = system(command);
    if (ret) {
        puts("Verdict: Compile Error.");
    } else {
        if (argc == 3)
            sprintf(command, "bin\\main.exe < in.txt");
        else if (argc == 4)
            sprintf(command, "bin\\main.exe < in.txt > out.txt");
        else sprintf(command, "bin\\main.exe");
        printf("Command: %s\n", command);
        puts("================");
        clock_t st =clock();
        ret = system(command);
        clock_t ed = clock();
        puts("================");
        if (ret)
            puts("Verdict: Runtime Error");
        else {
            puts("Run successfully");
            printf("Time used: %dms\n", ed-st);
        }
    }
    return 0;
}
